function isValueEmpty(value){ var re = /^\s+$/; if(value.length==0 || re.test(value)) return true; return false; }
function isValueBrackets(value){ var re = /[)(]+/; if(value.length==0 || re.test(value)) return true; return false; }
function isCheckDate(value){ var re = /^\d{2}\/\d{2}\/\d{4}$/; if(value.length==0 || re.test(value)) return true; return false; }
function isValueInteger(value){ var re = /^\d+$/; if(re.test(value)) return true; return false; }
function isValidEmail(value){var re = /^[A-Z0-9\._%+\-]+@[A-Z0-9\.\-]+\.[A-Z]{2,6}$/i; if(re.test(value)) return true; return false; }
function isValidColour(value){var re = /^#[\da-f]{6}$/i; if(re.test(value)) return true; return false; }
function isValidDate(value){var rExp =  /^(?:0[1-9]|[12][0-9]|3[01])\/(?:0[1-9]|1[0-2])\/[0-9]{4}$/;
if(!rExp.test(value)) return false; else return true;} function doNothing(){ document.body.style.cursor = "default"; };
function isValidAlphanum(value){var re = /^[A-Za-z0-9]+$/; if(re.test(value)) return true; return false;}
function isValidNum(value){ var re = /(^\d+$)|(^\d+\.\d+$)/; if(re.test(value)) return true; return false; }
function isValidAlphanum_(value){var re = /^[A-Za-z0-9_]+$/; if(re.test(value)) return true; return false;}
function hideElement(element_id){document.getElementById(element_id).style.display="none";}
function showElement(element_id){document.getElementById(element_id).style.display="";}
function getElement(element_id){return document.getElementById(element_id)}
function setInnerHTML(element_id,value){document.getElementById(element_id).innerHTML=value;}
function hasSpecialSymbols(element_id){var re = /[><\/%`|:&!'" $*]+/; 
var value = document.getElementById(element_id).value; if(re.test(value))return true;return false;}
/** convert mm/dd/yyyy to dd/mm/yyyy || dd/mm/yyyy to mm/dd/yyyy */
function ConvertDate(date){ var dateArr = date.split('/'); return dateArr[1]+'/'+dateArr[0]+'/'+dateArr[2]; }
function removeSpaces(a) { var allSpacesRe = /\s+/g; return a.replace(allSpacesRe, "");}
Array.prototype.in_array = function(obj) {
 var len = this.length;
 for(var x = 0 ; x <= len ; x++ ){ if ( this[x] == obj ) return true; }
 return false;
}
function getOffset(el){ var offset; offset.left = el.offsetLeft; offset.top = el.offsetTop ; return offset; }
function getElementsByName_iefix(tag, name){
 var elem = document.getElementsByTagName(tag);
 var arr = new Array();
 for(i = 0,iarr = 0; i < elem.length; i++) {
  att = elem[i].getAttribute("name");
  if(att == name) { arr[iarr] = elem[i]; iarr++; }
 }return arr;
}
function PageReload(){document.location.href=document.location.href;}
function check_all_checkboxes(name)
{
    var state = true; var checkboxes = getElementsByName_iefix('input',name);
    if(checkboxes[0] && checkboxes[0].checked == true)state = false;
    for (var i = 0; i < checkboxes.length; i++) checkboxes[i].checked = state;
} 
function get_all_checked_commasepareted(name){
var ret = ''; var checkboxes = getElementsByName_iefix('input',name);
for (var i = 0; i < checkboxes.length; i++) { if(checkboxes[i].checked) { if(checkboxes[i].value.indexOf('_')!=-1){ ret += (checkboxes[i].value.substr(checkboxes[i].value.indexOf('_')+1) + ","); } else { ret += (checkboxes[i].value + ","); } } }
return ret;
} 
function get_all_checked_count(name){
var count = 0; var checkboxes = getElementsByName_iefix('input',name);
for (var i = 0; i < checkboxes.length; i++) { if(checkboxes[i].checked) count++; }
return count;
} 
function set_all_checkbox_to(name,state){
var checkboxes = getElementsByName_iefix('input',name);
for (var i = 0; i < checkboxes.length; i++) {checkboxes[i].checked = state;}
} 
function get_all_checked_array(name){
var count = 0; var checkboxes = getElementsByName_iefix('input',name); var ret = new Array();
for (var i = 0; i < checkboxes.length; i++) { if(checkboxes[i].checked) { ret[count] = checkboxes[i]; count++; } }
return ret;
} 
function set_all_checkbox_to_false_except_this(name,value)
{
    var state = true; var checkboxes = getElementsByName_iefix('input',name);
    for (var i = 0; i < checkboxes.length; i++) 
    {
        if(checkboxes[i].value == value) checkboxes[i].checked = true;
        else checkboxes[i].checked = false;
    }
} 
